home *** CD-ROM | disk | FTP | other *** search
- 'WINDODMO.ASC -- MSDOS QuickBASIC WINDOW.SUB demonstration 25 June 86
- '| by David L. Poskie (608) 274-9560
- '| 7118 Raymond Rd. Madison, WI 53719
- '| Please run any suggestions, corrections, additions, or changes by me.
- '| I can be messaged on all the major Madison, WI RBBS's.
-
- DEFINT A-C,E-Z ' All variables except D are integers
- False = 0 ' (D must be SNG for Delay subroutine)
- True = NOT False
-
- ' The next two code lines come from WINDOW.SUB, where I have
- ' them commented out. This is my preference -- I like to see
- ' all the DIMensioning right up front in a main program. If you
- ' are less picky, you could uncomment them in WINDOW.SUB and omit
- ' writing these lines.
- DIM HSelect$(10) , VSelect$(10) , SaveWindow$(100)
- DIM NowX(20) , NowY(20) , NowWidth(20) , HeightNow(20)
- ' In general, NOW refers to the current window.
-
- GOTO Start
- 'You must include these two subroutine files to use windows
- Rem $Include: 'OMNI.SUB'
- Rem $Include: 'WINDOW.SUB'
-
- Start:
- 'Set and save the original screen attributes
- OldFG = 14
- OldBG = 3
- OldMG = 8
- COLOR OldFG , OldBG , OldMG
-
- CLS
- LOCATE 10 , 30
- PRINT "Microsoft QuickBASIC"
- LOCATE 12 , 20
- PRINT "Demonstration of WINDOW.SUB Subroutines"
-
- ' Set the screen attributes for the first window
- ScreenWidth = 80
- FG = 14
- BG = 6
- MG = 8
- COLOR FG , BG , MG
-
- ' Set the location & dimensions
- DoubleBox = True ' Use a double line box
- NewWindow = True
- X = 2
- Y = 2
- WWidth = 76
- WHeight = 19
-
- ' Make the window
- GOSUB AddWindow
-
- '| Display text on first window
- W = 1
- X = 6
- Y = 3
- Text$ = " This demonstration shows you how QuickBASIC can be used for"
- GOSUB WriteWindow
- Y = Y + 1
- Text$ = "making windows and menus. The delay you experienced in getting"
- GOSUB WriteWindow
- Y = Y + 1
- Text$="to here was caused by the routine that saved the information"
- GOSUB WriteWindow
- Y = Y + 1
- Text$ = "underlying this window."
- GOSUB WriteWindow
- Y = Y + 2
- Text$ = " Windows can help a program user understand what can be done"
- GOSUB WriteWindow
- Y = Y + 1
- Text$ = "at any given time in the program . They can provide a clear way of"
- GOSUB WriteWindow
- Y = Y + 1
- Text$ = "displaying multiple events on one screen. They can also be used for"
- GOSUB WriteWindow
- Y = Y + 1
- Text$ = " showing menu selections or other prompts, as demonstrated here."
- GOSUB WriteWindow
- Y = Y + 2
- Text$ = " To make a selection, just use the arrow keys to `point' to"
- GOSUB WriteWindow
- Y = Y + 1
- Text$ = "your choice. On a horizontal menu, use the left and right keys"
- GOSUB WriteWindow
- Y = Y + 1
- Text$ = "the select your choice. On a vertical, `pull-down' menu, use"
- GOSUB WriteWindow
- Y = Y + 1
- Text$ = "the up and down arrow keys. Once your selection has been made,"
- GOSUB WriteWindow
- Y = Y + 1
- Text$ = "press <CR>. That's all there is to it !"
- GOSUB WriteWindow
-
- MainLoop:
- DoubleBox = False ' Use a single line box
- W = 1
- HSelectWidth = 10
- HSelect$(1) = "Edit"
- HSelect$(2) = "Files"
- HSelect$(3) = "Print"
- HSelect$(4) = "Help"
- HSelect$(5) = "Exit"
- HNumSelects = 5
-
- '| Display horizontal menu
- GOSUB HMenu
-
- ON SelectNum GOSUB DoEdit , DoFile , DoPrint , DoHelp , DoExit
-
- NewWindow = False
-
- GOTO MainLoop
-
- '| Edit command selection
- DoEdit:
- W = 2
- X = 1
- Y = 1
-
- '| Display text
- Text$ = "Edit: Enter text, press <ESC> when finished "
- GOSUB WriteWindow
-
- WHILE KeyCode <> 27
- GOSUB GetKeyCode
- WEND
-
- RETURN
-
- '| Files command selection
- DoFile:
- VSelectWidth = 10
- VSelect$(1) = "Get"
- VSelect$(2) = "Save"
- VSelect$(3) = "Delete"
- VSelect$(4) = "Return"
- VNumSelects = 4
-
- '| Display pull-down menu
- GOSUB VMenu
-
- IF SelectNum = 4 _
- THEN GOSUB KillWindow : _
- RETURN
-
- '| Create a new window to display filename prompt
- X = NowX(NowWindow)
-
- IF X + 2 > ScreenWidth _
- THEN X = X - VSelectWidth - 2
-
- Y = NowY(NowWindow) + VNumSelects + 2
- WHeight = 1
- WWidth = 29
- GOSUB AddWindow
-
- ' Now X and Y are relative to the window
- X = 1
- Y = 1
- W = NowWindow
- Text$ = "Enter Filename: "
- Check = LEN(Text$)
- GOSUB WriteWindow
- X = CSRLIN
- Y = POS(0)
- KeyMax = 12
- Text$ = ""
- GOSUB GetKeyInput
-
- ' Show the input
- TempX = CSRLIN : TempY = POS(0)
- LOCATE X , Y - Check
- PRINT " You entered: "; Text$;
- LOCATE TempX , TempY
- SOUND 2222 , 1
- Dly = 2
- GOSUB Delay
-
- ' Remove filename window
- GOSUB KillWindow
-
- ' Remove files window
- GOSUB KillWindow
- RETURN
-
- '| Print command selection
- DoPrint:
- ' Set up & display pull-down menu
- VSelectWidth = 12
- VSelect$(1) = "to Printer"
- VSelect$(2) = "to File"
- VSelect$(3) = "Return"
- VNumSelects = 3
- GOSUB VMenu
-
- ' Evaluate selection
- IF SelectNum = 3 _
- THEN GOSUB KillWindow : _
- RETURN
-
- IF SelectNum = 1 _
- THEN PrintFlag = 1 : _
- GOSUB KillWindow : _
- RETURN
-
- X = NowX(NowWindow)
- Y = NowY(NowWindow) + VNumSelects + 2
-
- ' Check for X out of bounds
- IF X + 2 > ScreenWidth _
- THEN X = X - VSelectWidth - 2
-
- ' Create a window for prompt
- WHeight = 1
- WWidth = 29
- GOSUB AddWindow
-
- '| Make sure window will fit
- IF X + WWidth + 2 > ScreenWidth _
- THEN X = ScreenWidth - WWidth - 2
-
- X = 1
- Y = 1
- W = NowWindow
-
- ' Display filename prompt
- Text$="Enter filename: "
- GOSUB WriteWindow
-
- X = CSRLIN
- Y = POS(0)
- KeyMax = 12
- Text$ = ""
- GOSUB GetKeyInput
-
- ' Show the input
- TempX = CSRLIN : TempY = POS(0)
- LOCATE X , Y - Check
- PRINT " You entered: "; Text$;
- LOCATE TempX , TempY
-
- SOUND 2222 , 1
- Dly = 2
- GOSUB Delay
-
- ' Remove the filename window
- GOSUB KillWindow
-
- ' Remove print window
- GOSUB KillWindow
- RETURN
-
- '| Help selection
- DoHelp:
- VSelectWidth = 12
- VSelect$(1) = "for Edit"
- VSelect$(2) = "for Files"
- VSelect$(3) = "for Print"
- VSelect$(4) = "Return"
- VNumSelects = 4
-
- ' Display pull-down menu
- GOSUB VMenu
-
- IF SelectNum = 4 _
- THEN GOSUB KillWindow : _
- RETURN
-
- '| Create a new window to display help
- X = NowX(NowWindow)
-
- IF X + 2 > ScreenWidth _
- THEN X = X - VSelectWidth - 2
-
- Y = NowY(NowWindow) + VNumSelects + 2
- WHeight = 9
- WWidth = 22 + LEN(VSelect$(SelectNum))
- GOSUB AddWindow
-
- ' Now X and Y are relative to the window
- X = 2
- Y = 5
- W = NowWindow
- Text$ = "This is dummy Help " + VSelect$(SelectNum) + "."
- GOSUB WriteWindow
-
- SOUND 2222 , 1
- Dly = 3
- GOSUB Delay
-
- ' Remove filename window
- GOSUB KillWindow
-
- ' A real program would have printed help here
-
- ' Remove the menu
- GOSUB KillWindow
- RETURN
-
- '| Exit program
- DoExit:
- GOSUB KillWindow
- GOSUB KillWindow
- LOCATE 12,1
- PRINT SPC(36);"Goodbye ! "
-
- SYSTEM
- ' >>>>> Physical EOF WINDODMO.ASC 25 June 86